package com.supcon.exchangedata.repository.slave5;

import com.supcon.exchangedata.pojo.entity.mysql.operation.hj.GasDailyOpertionInfo;
import com.supcon.exchangedata.pojo.entity.mysql.operation.rq.GasLiquidInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.util.List;

public interface SlaveGasLiquidInfo extends JpaRepository<GasLiquidInfo, Long> {

    List<GasLiquidInfo> findAll();



    @Transactional
    @Query(nativeQuery = true, value = "SELECT * FROM gas_liquid_daily_operation_info WHERE day = ?1")
    GasLiquidInfo findByDay(String day);

    @Transactional
    @Query(nativeQuery = true, value = "SELECT * FROM gas_liquid_daily_operation_info WHERE data_time = (SELECT MAX(data_time) FROM gas_liquid_daily_operation_info)")
    GasLiquidInfo findTopData(LocalDateTime dateTime);

    GasLiquidInfo findByDataTime(LocalDateTime dataTime);
}
